//
//  UIViewController+Alert.m
//  ExhibitionHall
//
//  Created by 王洋 on 2019/6/24.
//  Copyright © 2019 王洋. All rights reserved.
//

#import "UIViewController+Alert.h"

@implementation UIViewController (Alert)

@dynamic block;

- (void)alert:(NSString *)message {
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:nil];
    [alert addAction:action];
    UIViewController *vc = [[UIApplication sharedApplication] keyWindow].rootViewController;
    [vc presentViewController:alert animated:YES completion:nil];
}

- (void)alert:(NSString *)message leftTitle:(NSString *)left Action:(void(^)(UIAlertAction * _Nonnull action))leftAction rightTitle:(NSString *)right Action:(void(^)(UIAlertAction * _Nonnull action))rightAction {
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *leftA = [UIAlertAction actionWithTitle:left style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        leftAction(action);
    }];
    
    [alert addAction:leftA];
    
    UIAlertAction *rightA = [UIAlertAction actionWithTitle:right style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        rightAction(action);
    }];
    [alert addAction:rightA];
    
    UIViewController *vc = [[UIApplication sharedApplication] keyWindow].rootViewController;
    [vc presentViewController:alert animated:YES completion:nil];
}


@end
